package org.example.node;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liyishan
 * @date 2024/6/14 09:48
 * @apiNote
 */

public class Test00590Postorder {

    public List<Integer> postorder(Node root) {
        List<Integer> ans = new ArrayList<>();
        helper(root,ans);
        return ans;
    }

    public void helper(Node root,List<Integer> res){
        if(root == null){
            return;
        }
        for(Node node: root.children){
            helper(node,res);
        }
        res.add(root.val);
    }
}
